#include "Defs.h"
#include "RuleLength.h"


RuleLength_T::RuleLength_T(const char * szName, const char * szRootSection, const char * szConfigFile)
	:flag(false)
	,len((unsigned int)-1)
{
	FillMemory(_szName, sizeof(_szName), 0);
	_snprintf(_szName, sizeof(_szName) - 1, szName);

	len = GetPrivateProfileInt(szRootSection, _szName, -1, szConfigFile);
	flag = len != -1;
}

void RuleLength_T::ToString(char * szBuffer, unsigned int bufferSize)
{
	unsigned int bufferCursor = 0;

	if( flag )
	{
		_snprintf(szBuffer + bufferCursor, bufferSize - 1 - bufferCursor, 
			"# %s=%d\r\n", _szName, len);
		bufferCursor = lstrlen(szBuffer);
	}
}